import request from '../../utils/request';
import config from '../../utils/config';

const { api } = config;
const { employee: {
  findEmployeeInfos,
  findEmployeeList,
} } = api;

type FindEmployeeInfosInput = {
	keyword?: string, // 搜索词人员姓名模糊搜索
	dept?: string, // 营业部逻辑营业部in
	dispSelf?: string, // 是否展示自己不选默认1；0|否；1|是
}
type FindEmployeeInfosOutput = {
  code: number,
  note: string,
  records: {
		empId: string,	//员工ID
		empName: string,	//员工姓名
		empNo: string,	//员工编码
		dept: string,	//营业部
		deptName: string,	//营业部名称
	}[]
};
// 查询员工信息
export async function FindEmployeeInfos(payload: FindEmployeeInfosInput): Promise<FindEmployeeInfosOutput> {
  const option = {
    url: findEmployeeInfos, // crm/v1/employee/search
    method: 'GET',
    data: payload,
  };
  return request(option);
}

type FindEmployeeListInput = {
	keyword?: string, // 搜索词人员姓名模糊搜索
	dept?: string, // 营业部逻辑营业部in
}
type FindEmployeeListOutput = {
  code: number,
  note: string,
  records: {
		empId: string,	//员工ID
		empName: string,	//员工姓名
		dept: string,	//营业部
		deptName: string,	//营业部名称
		userId: Array<any>,	//userIdtuser.id
		empNum: string,	//工号tuser.userid
	}[]
};
// 查询员工列表
export async function FindEmployeeList(payload: FindEmployeeListInput): Promise<FindEmployeeListOutput> {
  const option = {
    url: findEmployeeList, // crm/v1/employee/list
    method: 'GET',
    data: payload,
  };
  return request(option);
}
